package com.hzhq.contract.convert;

import com.hzhq.contract.bean.dto.ContractTypeDTO;
import com.hzhq.contract.bean.entity.ContractType;
import com.hzhq.contract.bean.vo.ContractTypeVO;
import com.hzhq.contract.bean.vo.ContractVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @author: hzhq1255
 * @mail: hzhq1255@163.com
 * @date: 2021/4/18 21:44
 * @desc:
 */
@Mapper
public interface ContractTypeConvertBasic {

    ContractTypeConvertBasic INSTANCE = Mappers.getMapper(ContractTypeConvertBasic.class);

    ContractTypeDTO poToDto(ContractType source);

    ContractType dtoToPo(ContractTypeDTO source);

    @Mappings({
            @Mapping(target = "typeId", expression = "java(com.hzhq.contract.util.ConvertUtil.objectIdToString(source.getTypeId()))")
    })
    ContractTypeVO dtoToVo(ContractTypeDTO source);

    @Mappings({
            @Mapping(target = "typeId", expression = "java(com.hzhq.contract.util.ConvertUtil.stringToObjectId(source.getTypeId()))"),
            @Mapping(target = "deleted", expression = "java(com.hzhq.contract.status.DefaultValue.NOT_DELETED)")
    })
    ContractTypeDTO voToDto(ContractTypeVO source);

}
